﻿using System;
using System.Xml.Serialization;

namespace DivShare
{
    /// <summary>
    /// Provides webfile specific data.
    /// </summary>
    [Serializable]
    public class WebFileInfo
    {
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        [XmlElement(ElementName="file_id")]
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        [XmlElement(ElementName = "file_name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        [XmlElement(ElementName = "file_description")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the file size.
        /// </summary>
        /// <value>The file size.</value>
        [XmlElement(ElementName = "file_size")]
        public decimal Size { get; set; }

        /// <summary>
        /// Gets or sets the number of downloads.
        /// </summary>
        /// <value>The number of downloads.</value>
        [XmlElement(ElementName = "downloads")]
        public int DownloadCount { get; set; }

        /// <summary>
        /// Gets or sets the webfile's last download time in UNIX time format.
        /// </summary>
        /// <value>The webfile's last download time in UNIX time format.</value>
        [XmlElement(ElementName = "last_downloaded_at")]
        public int LastDownloadUnixTime { get; set; }

        /// <summary>
        /// Gets or sets the webfile's upload time in UNIX time format.
        /// </summary>
        /// <value>The webfile's upload time in UNIX time format.</value>
        [XmlElement(ElementName = "uploaded_at")]
        public int UploadUnixTime { get; set; }

        /// <summary>
        /// Gets or sets the folder id where the webfile is located.
        /// </summary>
        /// <value>The folder id where the webfile is located.</value>
        [XmlElement(ElementName = "folder_id")]
        public string FolderId { get; set; }

        /// <summary>
        /// Gets or sets the folder title where the webfile is located.
        /// </summary>
        /// <value>The folder title where the webfile is located.</value>
        [XmlElement(ElementName = "folder_title")]
        public string FolderTitle { get; set; }

        /// <summary>
        /// Gets or sets the webfile's last download time.
        /// </summary>
        /// <value>The webfile's last download time.</value>
        public DateTime LastDownloadTime 
        {
            get { return UnixDateTimeHelper.ConvertToDateTime(LastDownloadUnixTime); }
            set { LastDownloadUnixTime = UnixDateTimeHelper.Parse(value); }
        }

        /// <summary>
        /// Gets or sets the webfile's upload time.
        /// </summary>
        /// <value>The webfile's upload time.</value>
        public DateTime UploadTime 
        {
            get { return UnixDateTimeHelper.ConvertToDateTime(UploadUnixTime); }
            set { UploadUnixTime = UnixDateTimeHelper.Parse(value); }
        }

    }
}
